﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Outpatient.Migrations
{
    /// <inheritdoc />
    public partial class add_table_OtpMdtrtRec : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "OtpMdtrtRec",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    MdtrtSn = table.Column<string>(type: "text", nullable: false),
                    PatnId = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpNo = table.Column<string>(type: "text", nullable: false),
                    PatnName = table.Column<string>(type: "text", nullable: false),
                    OtpRgstTypeId = table.Column<Guid>(type: "uuid", nullable: false),
                    DeptId = table.Column<Guid>(type: "uuid", nullable: false),
                    DeptCodg = table.Column<string>(type: "text", nullable: false),
                    DeptName = table.Column<string>(type: "text", nullable: false),
                    DrId = table.Column<Guid>(type: "uuid", nullable: false),
                    DrCodg = table.Column<string>(type: "text", nullable: false),
                    DrName = table.Column<string>(type: "text", nullable: false),
                    MdtrtTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    Chfcomp = table.Column<string>(type: "text", nullable: true),
                    Illhis = table.Column<string>(type: "text", nullable: true),
                    Algs = table.Column<string>(type: "text", nullable: true),
                    AiseCode = table.Column<string>(type: "text", nullable: true),
                    Phex = table.Column<string>(type: "text", nullable: true),
                    AsstExam = table.Column<string>(type: "text", nullable: true),
                    RxRec = table.Column<string>(type: "text", nullable: true),
                    SympName = table.Column<string>(type: "text", nullable: true),
                    SympCode = table.Column<string>(type: "text", nullable: true),
                    DspoOpnn = table.Column<string>(type: "text", nullable: true),
                    AttkTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    FstdiagFlag = table.Column<bool>(type: "boolean", nullable: false),
                    OtpMdtrtStas = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpMdtrtRec", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "OtpDiagRecs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpMdtrtRecId = table.Column<Guid>(type: "uuid", nullable: false),
                    TcmDiagFlag = table.Column<int>(type: "integer", nullable: false),
                    DiagTypeCode = table.Column<string>(type: "text", nullable: false),
                    DiagTypeName = table.Column<string>(type: "text", nullable: false),
                    DiagCode = table.Column<string>(type: "text", nullable: false),
                    DiagName = table.Column<string>(type: "text", nullable: false),
                    TcmDiseCode = table.Column<string>(type: "text", nullable: false),
                    TcmDiseName = table.Column<string>(type: "text", nullable: false),
                    TcmsympCode = table.Column<string>(type: "text", nullable: false),
                    Tcmsymp = table.Column<string>(type: "text", nullable: false),
                    DeptId = table.Column<Guid>(type: "uuid", nullable: false),
                    DrId = table.Column<Guid>(type: "uuid", nullable: false),
                    DiagTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    Srtno = table.Column<int>(type: "integer", nullable: false),
                    SuspFlag = table.Column<bool>(type: "boolean", nullable: false),
                    UpdFlag = table.Column<bool>(type: "boolean", nullable: false),
                    ValiFlag = table.Column<bool>(type: "boolean", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpDiagRecs", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OtpDiagRecs_OtpMdtrtRec_OtpMdtrtRecId",
                        column: x => x.OtpMdtrtRecId,
                        principalSchema: "Outpatient",
                        principalTable: "OtpMdtrtRec",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_OtpDiagRecs_OtpMdtrtRecId",
                table: "OtpDiagRecs",
                column: "OtpMdtrtRecId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OtpDiagRecs");

            migrationBuilder.DropTable(
                name: "OtpMdtrtRec",
                schema: "Outpatient");
        }
    }
}
